package com.googlecode.imanager.swing;

import java.awt.Graphics;

import javax.swing.JLabel;

import com.googlecode.imanager.client.Label;
import com.googlecode.imanager.client.bridge.ILabel;
import com.googlecode.imanager.core.base.BridgeApplication;

/**
 * @author wellsantos@wellsantos.com
 * @since 0.01
 */
public class SwingLabel extends SwingControl implements ILabel {
    
    public SwingLabel(BridgeApplication bridge, Label source) {
        super(bridge, source);
    }

    @Override
    protected JLabel createTarget() {
        class Target extends JLabel {
            private static final long serialVersionUID = 1L;

            @Override
            protected void paintComponent(Graphics g) {
                
                if (isBackgroundSet()){
                    g.setColor(getBackground());
                    g.fillRect(0, 0, getWidth(), getHeight());
                }
                super.paintComponent(g);
            }
            
        }
        
        return new Target();
    }

    @Override
    public JLabel getTarget(){
        return (JLabel) target;
    }
    
    @Override
    public Label getSource() {
        return (Label) source;
    }

    public void setText(String text) {
        getTarget().setText(text);
    }
    
    public void setOverflowVert(boolean overflowVert) {
        // TODO Auto-generated method stub
    }
    
    public void setOverflowHorz(boolean overflowHorz) {
        // TODO Auto-generated method stub
    }

}
